<?php
/**
 * Created by PhpStorm.
 * User: HaYiiRo
 * Date: 2018/1/27
 * Time: 15:44.
 */

namespace App\Model\Admin;

use App\Model\Common\Common as C;

class Admin extends C
{
    public function setPasswordAttribute($value)
    {
        if ($value) {
            $this->salt = rand(1000, 9999);

            $this->attributes['password'] = md5($value.$this->salt);
        }
    }

    public function checkPassword($password)
    {
        if ($this->password == md5($password.$this->salt)) {
            return true;
        } else {
            return false;
        }
    }
}
